﻿#region Revision info
/*
 * $Author: millz $
 * $Date: 2013-08-18 06:57:33 +0100 (Sun, 18 Aug 2013) $
 * $ID$
 * $Revision: 121 $
 * $URL: https://subversion.assembla.com/svn/honorbuddy-Portal/trunk/Portal/RotationBase.cs $
 * $LastChangedBy: millz $
 * $ChangesMade$
 */
#endregion

using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Portal.Core;
using Portal.Helpers;
using Portal.Managers;
using Portal.Settings;
using Portal.Specialisation;
using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.Pathing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.TreeSharp;

namespace Portal
{
	public abstract class RotationBase
	{

		protected static LocalPlayer Me
		{
			get { return StyxWoW.Me; }
		}

        public abstract WoWSpec KeySpec { get; }

		public abstract Composite Rotation { get; }

		public abstract Composite PreCombat { get; }

		public abstract string Name { get; }

	    internal virtual void OnPulse()
	    {

            if (!Me.IsValid || !StyxWoW.IsInWorld || Me == null)
            {
                return;
            }

            #region Out of Combat Buff Pulse
            if (DateTime.Compare(DateTime.Now, _lastPulseTime.AddMilliseconds(1000)) > 0 
                && Me.IsValid && !Me.IsDead && !Me.Combat && !SpellManager.GlobalCooldown && !Me.IsCasting && !Me.IsChanneling)
            {
                _lastPulseTime = DateTime.Now;

                #region Self Buffs
                if (!Me.Mounted && !Me.HasAnyAura("Food", "Drink"))
                {
                    if (PortalSettings.Instance.IceBarrierCondition == 0 && TalentManager.HasTalent(6) && !Me.HasAura("Ice Barrier"))
                    {
                        SpellManager.Cast("Ice Barrier");
                    }
                }
                #endregion

            }
            #endregion


        }

        private static DateTime _lastPulseTime;
	}
}
